import api from "@/api/index.js"
import { getToken } from '@/utils/user.js'
import {ref} from "vue"
const keyword = ref('')
const keywordItem = ref([])
const hotList = ref([])
export { keyword, keywordItem, hotList }
const useHot = () => {
  api.getHotSearch().then((res) => {
    hotList.value = res.data ?? []
    const len = hotList.value.length
    let hotIndex = 0
    keyword.value = hotList.value?.[hotIndex]?.keyword
    keywordItem.value = hotList.value?.[hotIndex]
    setInterval(() => {
      hotIndex += 1
      if (hotIndex > len - 1) {
        hotIndex = 0
      }
      keyword.value = hotList.value[hotIndex]?.keyword
      keywordItem.value = hotList.value?.[hotIndex]
    }, 4000)
  })
}
 const token = getToken()
if(token){
  console.log(111111111111)
  // useHot()
}
